-- Copyright (c) 2025 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--         http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Create: 2025-7-21
-- Description: all constants.

local const = {}
const.__index = const

const.SKYNET_ONE_SECOND = 100  -- 通过skynet延时的时间单位（100/秒）
const.TICK_ONE_SECOND = 1000  -- 每秒为1000ms

const.DEFAULT_SOFT_HEARTBEAT_COUNTDOWN = 60000 -- 默认心跳计数为60000次，即每1次/10ms，至少维持10min

const.AS_CHECK_STATE_WAIT_BOARD_IN = 0  -- 0表示初始状态，需要检测是否插稳
const.AS_CHECK_STATE_ACTIVE_CHECK = 1  -- 1表示当前正在检测信号，判断主备状态
const.AS_CHECK_STATE_IN_ACTIVE = 2  -- 2表示当前已处于Active状态，并持续检信号
const.AS_CHECK_STATE_IN_STANDBY = 3  -- 3表示当前已处于Standby状态，并持续检测信号

const.BOARD_IN_OK = 1  -- 1表示单板插稳
const.BOARD_IN_NOT_OK = 0  -- 0表示单板未插稳
const.BOARD_IN_COUNT_THRESHOLD = 1000  -- 插稳状态每检测1000次记录异常日志

const.BOARD_PRESENT = 1  -- 1表示单板在位
const.BOARD_NOT_PRESENT = 0  -- 0表示单板不在位

const.BOARD_NOT_HEALTH = 0  -- 0表示单板不健康
const.BOARD_HEALTH = 1  -- 1表示单板健康
const.BOARD_HEALTH_SIGNAL_FAULT = 2  -- 2表示单板健康信号丢失

const.ACTIVE_STATE = 1  -- 1表示当前状态为Active
const.STANDBY_STATE = 0  -- 0表示当前状态为Standby

const.FAILOVER_OCCURRED_BY_INIT_STATE = 0  -- 0表示初始化状态，没有请求任务
const.FAILOVER_OCCURRED_BY_RPC = 1  -- 1表示接口倒换
const.FAILOVER_OCCURRED_BY_SWITCH_RULE = 2  -- 2表示切换条件倒换

const.FAILOVER_CHECK_SUCCESS = 0  -- 0表示检测允许倒换
const.FAILOVER_FAILED_REASON_REMOTE_NOT_HEALTH = 2  -- 2表示远端健康状态异常
const.FAILOVER_FAILED_REASON_REMOTE_NETWORK_DISCONNECT = 3  -- 3表示远端网络异常
const.FAILOVER_FAILED_REASON_LOCAL_CRITICAL_EVENT = 4  -- 4表示本端有异常例如获取寄存器失败
const.FAILOVER_FAILED_REASON_RESTRAIN = 7  -- 7表示倒换被抑制
const.FAILOVER_FAILED_REASON_BOARD_IN_NOT_OK = 8  -- 8表示没有插稳导致失败
const.FAILOVER_FAILED_REASON_LOCAL_HEATBEAT_ABNORMAL = 13  -- 13表示心跳异常
const.FAILOVER_FAILED_REASON_BUTT = 32  -- 0x20(32)表示被切换条件抑制，需要输出配置的错误信息
const.FAILOVER_FAILED_REASON_OTHER = 33  -- 0x21(33)其他类型的错误

const.SWITCH_RULE_TYPE_ALLOW = 0  -- 0：主动切换条件
const.SWITCH_RULE_TYPE_NOT_ALLOW = 1  -- 1：禁止切换条件
const.SWITCH_RULE_OPERATOR_GREATER = 1  -- 1：大于
const.SWITCH_RULE_OPERATOR_GREATER_EQUAL = 2  -- 2：大于等于
const.SWITCH_RULE_OPERATOR_LESS = 3  -- 3：小于
const.SWITCH_RULE_OPERATOR_LESS_EQUAL = 4  -- 4：小于等于
const.SWITCH_RULE_OPERATOR_EQUAL = 5  -- 5：等于
const.SWITCH_RULE_OPERATOR_NOT_EQUAL = 6  -- 6：不等于
const.SWITCH_RULE_DIRECTION_STANDBY = 0  -- 0: 降备
const.SWITCH_RULE_DIRECTION_ACTIVE = 1  -- 1: 升主

return const